<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>事件委托</title>
    <style>
        ul{
            cursor: pointer;
        }
    </style>
</head>
<body>
    <ul>
        <li>第一个元素</li>
        <li>第二个元素</li>
        <li>第三个元素</li>
        <li>第四个元素</li>
        <li>第五个元素</li>
        <p>p标签</p>
    </ul>
    <script>
        const ul = document.querySelector('ul')
        ul.addEventListener('click',function(e){
            if(e.target.tagName==='LI')
            e.target.style.color='red'
        })
    </script>
</body>
</html>